﻿using System;

namespace Narwhunderful.Aphelia.Framework.IO.Serialization.Binary
{

    public static class Elements
    {

        public const byte Collection = 1;
        public const byte ComplexObject = 2;
        public const byte Dictionary = 3;
        public const byte MultiArray = 4;
        public const byte Null = 5;
        public const byte SimpleObject = 6;
        public const byte SingleArray = 7;
        public const byte ComplexObjectWithId = 8;
        public const byte ComplexObjectReference = 9;
    }

    public static class SubElements
    {
        ///<summary>
        ///</summary>
        public const byte Dimension = 51;

        ///<summary>
        ///</summary>
        public const byte Dimensions = 52;

        ///<summary>
        ///</summary>
        public const byte Item = 53;

        ///<summary>
        ///</summary>
        public const byte Items = 54;

        ///<summary>
        ///</summary>
        public const byte Properties = 55;

        ///<summary>
        ///</summary>
        public const byte Unknown = 254;

        ///<summary>
        ///</summary>
        public const byte Eof = 255;
    }

    public class Attributes
    {
        ///<summary>
        ///</summary>
        public const byte DimensionCount = 101;

        ///<summary>
        ///</summary>
        public const byte ElementType = 102;

        ///<summary>
        ///</summary>
        public const byte Indexes = 103;

        ///<summary>
        ///</summary>
        public const byte KeyType = 104;

        ///<summary>
        ///</summary>
        public const byte Length = 105;

        ///<summary>
        ///</summary>
        public const byte LowerBound = 106;

        ///<summary>
        ///</summary>
        public const byte Name = 107;

        ///<summary>
        ///</summary>
        public const byte Type = 108;

        ///<summary>
        ///</summary>
        public const byte Value = 109;

        ///<summary>
        ///</summary>
        public const byte ValueType = 110;
    }

    public static class NumberSize
    {
        public const byte Zero = 0;
        public const byte B1 = 1;
        public const byte B2 = 2;
        public const byte B4 = 4;

        public static byte GetNumberSize(int value)
        {
            if (value == 0) return Zero;
            if (value > Int16.MaxValue || value < Int16.MinValue) return B4;
            if (value < byte.MinValue || value > byte.MaxValue) return B2;
            return B1;
        }

    }

}
